package com.xcity.game.activity.newplayer.tracer;

import java.text.MessageFormat;

import com.xcity.game.activity.newplayer.NewPlayerDoingStr;
import com.xcity.game.activity.newplayer.NewPlayerTask;
import com.xcity.game.activity.newplayer.NewPlayerTracer;
import com.xcity.game.activity.newplayer.NewPlayerTracerLabel;

@NewPlayerTracerLabel(NewPlayerTracer.ADVENTURE_COUNT)
public class AdventurePlayTracer implements NewPlayerTracer {

	@Override
	public boolean isDone(NewPlayerTask task) {
		if(task.getProgress()[0] >= task.getTemplate().getParam()[0]){
			return true;
		}
		return false;
	}

	@Override
	public void onChange(NewPlayerTask task, Object... vals) {
		int[] progress = task.getProgress();
		progress[0] += 1;
		if(progress[0] > PARAM0_MAX){
			progress[0] = PARAM0_MAX;
		}
	}

	@Override
	public String getDoingStr(NewPlayerTask task) {
		return MessageFormat.format(NewPlayerDoingStr.STR_ADVENTURE_COUNT, task.getProgress()[0], task.getTemplate().getParam()[0]);
	}

}
